/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.krossk.jpa;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Henrique
 */
public class JPAFactory {
    private static EntityManagerFactory emf = null;

    public static void initEMF(){
        if(emf!=null)
            return;
        emf = Persistence.createEntityManagerFactory("KrosskPU");
    }

    public static void destroyEMF(){
        if(emf==null)
            return;
        emf.close();
    }

    public static EntityManager getEntityManager(){
        return emf.createEntityManager();
    }

}
